package main

import (
	"gitee.com/dark.H/gs"
	"gitee.com/dark.H/gt"
)

func main() {

	p := gt.NewListItemsPanel(gs.List[string]{
		"Hello asfHello asf",
		"Wor,dHello asfads",
		"ASfsfHello asfsdf",
		"Hello asfHello asf",
		"Wor,dHello asfasdgd",
		"ASfsfHello asfasdg",
		"Hello asHello asff",
		"Wor,dHello asfadsg",
		"ASfsHello asffadsgadsg",
		"Hello aHello asfsf123",
		"Wor,Hello asfd12412",
		"ASfHello asfsf124124",
		"Hello asf Hello asf\", asdfadsf asdffasdfadsfasdfasdfasdf",
		"Wor,dHello asf Hello asf\", asdfadsf asdffasdfadsfasdfasdfasdf",
		"ASfsfHello asf Hello asf\", asdfadsf asdffasdfadsfasdfasdfasdf",
		"Hello asfHello asf Hello asf\", asdfadsf asdffasdfadsfasdfasdfasdf",
		"Wor,d",
		"ASfsf",
		"Hello asf",
		"Wor,dHello asf Hello asf\", asdfadsf asdffasdfadsfasdfasdfasdf",
		"ASfsfHello asf Hello asf\", asdfadsf asdffasdfadsfasdfasdfasdf",
		"Hello asfHello asf Hello asf\", asdfadsf asdffasdfadsfasdfasdfasdf",
		"Wor,d",
		"ASfsf",
		"Hello asf",
		"Wor,d",
		"ASfsf",
		"Hello asf",
		"Wor,d",
		"ASfsf",
		"Hello asf",
		"Wor,d",
		"ASfsf",
		"Hello asf",
		"Wor,d",
		"ASfsf",
		"Hello asf",
		"Wor,d",
		"ASfsf",
	})
	p.SetLoc(20, 20).SetSize(30, 30).SetBar(false)
	p.OnkeyEnter(func(parentPanel *gt.PanelHandler) bool {
		p.Label(gs.Str(p.Selected()))
		p.Switch(func(parentPanel *gt.PanelHandler) bool {
			x2, y2 := p.GetSelectPos(true)
			selected := p.Selected()
			p2 := gt.NewListItemsPanel(gs.List[string]{
				"item Hello asf",
				"item  Wor,d",
				"item  ASfsf",
			})
			p2.SetSizeWidth(30).SetLoc(x2, y2, true).SetBar(false)
			p2.SetTitle(gs.Str(selected))
			p2.Focus()

			return true
		})
		return false
	})
	p.OnSelected(func(item string) {
		p.Switch(func(parentPanel *gt.PanelHandler) bool {
			_, y2 := p.GetSelectPos(true)

			selected := p.Selected()
			p2 := gt.NewListItemsPanel(gs.List[string]{
				"item Hello asf",
				"item  Wor,d",
				"item  ASfsf",
			})

			p2.SetSizeWidth(30).SetLoc(p.LocX()+p.Width, y2, true).SetBar(false)
			p2.SetTitle(gs.Str(selected))
			p2.ClearArea(p.LocX()+p.Width, p.LocY(), p.Width, p.Height)
			p2.Draw()

			return true
		})
	})
	p.SetMouse(true)
	p.Focus()
}
